package com.facemox.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.facemox.bean.User;
import com.facemox.mapper.UserMapper;
import com.facemox.service.UserService;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    
    @Override
    public int add(User user) {
        userMapper.insert(user);
        int id = user.getUserId();
        return id;
    }

	@Override
	public List<User> getAll() {
		List<User> users = userMapper.getAll();
		return users;
	}

	@Override
	public User findById(String id) {
		User user = userMapper.findById(id);
		return user;
	}

	@Override
	public int updateById(User user) {
		int effectLine = userMapper.update(user);
		return effectLine;
	}

	@Override
	public int deleteById(String id) {
		int effectLine = userMapper.delete(id);
		return effectLine;
	}

    @Override
    public User getUserByUsername(String username) {
        User user = userMapper.getUserByUsername(username);
        return user;
    }
}
